/*
Copyright (C) 1996-1997 Id Software, Inc.

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 3
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

*/

#pragma once


#define MAX_PARTICLES	4096

extern int ramp1[];
extern int ramp2[];
extern int ramp3[];

#define PF_KILL			1
#define PF_NEVERDIE		2

// !!! if this is changed, it must be changed in d_ifacea.h too !!!
typedef struct particle_s
{
	// grav, dvel and time belong to the emitter
	vec3_t		org;
	vec3_t		vel;
	float		color;

	// precalced for writing to the vertex buffer
	unsigned	ColorHi;
	unsigned	ColorLo;
	unsigned	ColorTime;

	// properties/etc
	float		ramp;
	float		die;

	int			*ramptable;
	float		ramptime;
	int			rampdie;

	int			flags;

	struct particle_s	*next;
} particle_t;


typedef struct emitter_s
{
	vec3_t org;
	vec3_t dvel;
	vec3_t grav;
	float time;

	// number of particles that the emitter will actually draw
	int numparticles;

	// and the particles themselves follow
	particle_t *particles;

	struct emitter_s *next;
} emitter_t;


extern emitter_t *active_emitters;
extern emitter_t *free_emitters;
extern particle_t *free_particles;

void R_BeginParticles (void);
void R_EndParticles (void);
void R_DrawParticles (emitter_t *e);
